﻿using CommandLine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yy.options.sqlcmd
{
    /// <summary>
    /// 下载
    /// </summary>
    public class Sqlcmd : BaseOption
    {
        /// <summary>
        /// 
        /// </summary>
        [Option("sqlcmd", Required = false, HelpText = "执行sqlcmd")]
        public string ExecSqlcmd { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public override void OnExecute()
        {
            Exec("执行sqlcmd", () =>
            {
                if (string.IsNullOrEmpty(this.ExecSqlcmd))
                {
                    return;
                }

                SendMsg("正在执行sqlcmd，请稍候...");

                var config = new Config();

                var helper = new SqlcmdHelper(config.ExecutablePath, config.Server, config.UserId, config.Password, config.Database);

                helper.ExecuteQueryString("select * from unikm.dbo.isql");
            });
        }
    }
}
